*** Create Figure 5 ***

********************************************************************************
use "${clean}/who_counts_analysis.dta", clear


* Run Honest DiD robust inference test: MOB, ANY FOR, 1955
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe MOB b1950.Dyear, absorb(geo2_ma YOB reg_fe Arabic Female) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"


honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("Registration")
graph save "${output}/graphs/MOB_HDID.gph", replace
graph export "${output}/graphs/MOB_HDID.png", replace

restore

* Honest DiD Test: Schooling, ANY FOR
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe Schooling b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"


honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("Formal Schooling")
graph save "${output}/graphs/Schooling_HDID.gph", replace
graph export "${output}/graphs/Schooling_HDID.png", replace

restore

* Honest DiD Test: Years, ANY FOR
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe EDU_YRS b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"


honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("Formal Schooling, Years")
graph save "${output}/graphs/YRS_HDID.gph", replace
graph export "${output}/graphs/YRS_HDID.png", replace

restore

* Honest DiD Test: Lit, ANY FOR
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe French_Lit b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"


honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("French & Arabic Literacy")
graph save "${output}/graphs/LIT_HDID.gph", replace
graph export "${output}/graphs/LIT_HDID.png", replace

restore

* Honest DiD Test: CM2, ANY FOR
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe CM2 b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("Compulsory Schooling")
graph save "${output}/graphs/CM2_HDID.gph", replace
graph export "${output}/graphs/CM2_HDID.png", replace

restore

* Honest DiD Test: LIT, ANY FOR
preserve
drop if YOB < 1945
drop if YOB > 1955

*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara
drop if FR_Maroc!=1
drop if ma1994a_resident==2
drop if citizen==4
drop if nativity==2
drop if geo2alt_ma==504001391

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe LIT b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"


honestdid, pre(1/5) post(7/11) mvec(0.5(0.5)2)
honestdid, coefplot cached title("Literacy")
graph save "${output}/graphs/LIT_ANY_HDID.gph", replace
graph export "${output}/graphs/LIT_ANY_HDID.png", replace

restore

graph combine "${output}/graphs/MOB_HDID.gph" "${output}/graphs/Schooling_HDID.gph" "${output}/graphs/YRS_HDID.gph" "${output}/graphs/LIT_HDID.gph"
graph save "${output}/graphs/Figure3A.gph", replace
graph export "${output}/graphs/Figure3A.png", replace
